package com.xxg.socket.impl.test;

import com.xxg.socket.YmaSession;
import com.xxg.socket.impl.NettySocketServer;

/**
 * Created by game group on 2020/12/23.
 */
public class Server extends NettySocketServer {

    @Override
    public Object onOpen(YmaSession session) {
        System.out.println("客户端连接");
        send(session,"1".getBytes());
        return null;
    }

    @Override
    public Object onMessage(YmaSession session, Object message) {
        String res = new String((byte[]) message);
        System.out.println(res);
        int req = Integer.parseInt(res) + 1;
        send(session,String.valueOf(req).getBytes());
        return null;
    }

    public static void main(String[] args) {
        new Server().start();
    }
}
